﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Navigation;
using System.Windows.Resources;
using Microsoft.Phone.Controls;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Media;

namespace PhoneApp1
{
    public partial class MainPage : PhoneApplicationPage
    {
        private SoundEffect C;
        private SoundEffect D;
        private SoundEffect G;
        private SoundEffect A;
        private SoundEffect CD;
        private SoundEffect CG;
        private SoundEffect CA;
        private SoundEffect DG;
        private SoundEffect DA;
        private SoundEffect GA;
        private SoundEffect CDG;
        private SoundEffect CDA;
        private SoundEffect CGA;
        private SoundEffect DGA;
        private SoundEffect CDGA;
        private GameTimer player;
        private bool[,] chords;
        private int timercolumn;


        // Constructor
        public MainPage()
        {
            InitializeComponent();

            GameTimer gameTimer = new GameTimer();
            gameTimer.UpdateInterval = TimeSpan.FromMilliseconds(20);

            // Call FrameworkDispatcher.Update to update the XNA Framework internals.
            gameTimer.Update += delegate { try { FrameworkDispatcher.Update(); } catch { } };

            // Start the GameTimer running.
            gameTimer.Start();

            player = new GameTimer();
            

         // Prime the pump or we'll get an exception.
            FrameworkDispatcher.Update();
            timercolumn = 0;
            chords = new bool[8,4];
            
                                  
       }



        private void LoadSound(String SoundFilePath, out SoundEffect Sound)
        {
            // For error checking, assume we'll fail to load the file.
            Sound = null;

            try
            {
                // Holds informations about a file stream.
                StreamResourceInfo SoundFileInfo = App.GetResourceStream(new Uri(SoundFilePath, UriKind.Relative));

                // Create the SoundEffect from the Stream
                Sound = SoundEffect.FromStream(SoundFileInfo.Stream);

            }
            catch (NullReferenceException)
            {
                // Display an error message
                MessageBox.Show("Couldn't load sound " + SoundFilePath);
            }
        }

        private void button_Click(object sender, RoutedEventArgs e)
        {
            Page1.stopTimer();
            try
            {

                NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));

            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Can't play.");
            }
        }

       



        private void button2_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            Page1.stopTimer();
        }
    }

}